<?php
namespace app\admin\controller;
use app\common\controller\AdminController;
use chrome\ChromePhp;
use common\Common;
use uploadImg\UtilImage;
use app\common\model\blfyy\LibMusic;
/**
 * 音乐平台
 * @name Music.php
 * @package blfyy
 * @category controller
 * @link http://www.chanekeji.com
 * @author syben
 * @version 1.0
 * @copyright CHANGE INC
 * @since 2021-03-11
 */
class Music extends AdminController{
    private $lib_music;
	/**
	 * 构造函数
	 */
	function __construct() {
		parent::__construct ();
		$this->lib_music = new LibMusic();
	}
	
	/**
	 * 音乐平台列表页面
	 **/
	function musicList(){
	    $this->getSetMenu($this);
	    //日志记录
        $this->log(__CLASS__, __FUNCTION__, "音乐平台列表页面", 1, 'view');
		return $this->fetch("Music/musicList/musicList");
	}
   
   	/**
     * 添加音乐平台页面
     */
    function addMusic(){
		$this->getMenu($this);
    	$this->log(__CLASS__, __FUNCTION__, "添加音乐平台页面", 1, 'add');
		return $this->fetch("Music/addMusic/addMusic");
    }

	/**
	 * 编辑音乐平台页面
	 */
	function editMusic(){
		$this->getMenu($this);
		$id = input('id');
		//查找消息
		$result = $this->lib_music->findMusic(array('id'=>$id));
		$this->assign('musicInfo',$result['data']);
		$this->log(__CLASS__, __FUNCTION__ ,"编辑音乐平台页面",1,'edit');
		return $this->fetch("Music/editMusic/editMusic");
	} 
	
	/**
	 * 插入音乐平台
	 */
	function insertMusic(){
		$data = $this->getArgsList($this, array('name','sort'));
		$result = $this->lib_music->addMusic($data);
		$this->log(__CLASS__, __FUNCTION__ ,"插入音乐平台",0,'add');
		echo json_encode($result);
	}
	
	/**
	 * 更新音乐平台
	 */
	function updateMusic(){
		$data = $this->getArgsList($this, array('name','sort'));
		$id = input('id');
		$conditions = array('id'=>$id);
		$result = $this->lib_music->updateMusic($conditions,$data);
		$this->log(__CLASS__, __FUNCTION__ ,"更新音乐平台",0,'edit');
		echo json_encode($result);
	}
	
	
	/**
	 * 删除音乐平台
	 */
	function deleteMusic(){
		$id = input('ids');
		$result = $this->lib_music->deleteMusic($id);
		$this->log(__CLASS__, __FUNCTION__ ,"删除音乐平台",0,'del');
		
		echo json_encode($result);
	}

	
	/**
	 * 音乐平台分页
	 */
	function pagingMusic(){
		$page = $this->getPageInfo($this);
		$sort = 'sort asc';
		$conditionList = $this->getPagingList($this, array('name' => 'like'));
		$result = $this->lib_music->pagingMusic( $page, $conditionList,$sort);
		$this->log(__CLASS__, __FUNCTION__ ,"音乐平台分页",0,'view');
		echo json_encode($result);
	}
}